package com.resumes.resumesdataservice.domain;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.List;
import java.util.UUID;

@Data
public class AllArgs {
    private String name;  //姓名·
    private String age; //年龄 ·
    private String contactinformation;//联系方式·
    private String email;//邮箱·
    private String major;//专业·
    private String jobintention;//求职意向·
    private String introduction;//自我介绍·
    private String skill;//技能·
    private String skills;//技能·
    private String award;//获奖情况·
    private String degree;//学历·
    private String awardprize;//获奖奖项·
    private String project;//项目经历·
    private String projects;//项目经历·

    //===========================================================
    private List<String> photopath;
    private List<String> filepath;
    private List<String> videopath;

    //将args中的数据分别转换为Student和ProjectExperience和AwardInformation
    public Student getStudent(){
        Student student = new Student();

        JSONObject jsonObject =  JSON.parseObject(skills);
        StringBuffer stringBuffer = new StringBuffer();
        for (Object o : jsonObject.values()) {
            stringBuffer.append(o);
            stringBuffer.append("\n");
        }

        student.setName(name);
        student.setAge(age);
        student.setEmail(email);
        student.setContactinformation(contactinformation);
        student.setMajor(major);
        student.setJobintention(jobintention);
        student.setIntroduction(introduction);
        student.setSkills(stringBuffer.toString());
        return student;
    }




    public ProjectExperience getProjectExperience(){
        ProjectExperience projectExperience = new ProjectExperience();
        projectExperience.setStudentId(getStudent().getId());
        projectExperience.setId(UUID.randomUUID().toString());
        try {
            projectExperience.setProjectinfo(project.split("\n")[1]);
            projectExperience.setProjectname(project.split("\n")[0]);
        } catch (Exception ignored) {
            projectExperience.setProjectinfo(project.split("\n")[0]);
            projectExperience.setProjectname(project.split("\n")[0]);
        }


        return projectExperience;
    }
    public AwardInformation getAwardInformation(){

        JSONObject jsonObject =  JSON.parseObject(awardprize);
        StringBuffer stringBuffer = new StringBuffer();
        for (Object o : jsonObject.values()) {
            stringBuffer.append(o);
            stringBuffer.append("\n");
        }

        AwardInformation awardInformation = new AwardInformation();
        awardInformation.setAwardprize(String.valueOf(stringBuffer));
        awardInformation.setId(UUID.randomUUID().toString());
        return awardInformation;
    }

}
